﻿var getUser = function getUser_(id, callback) {
    var url = "/api/users?id=".concat(id);
    $.getJSON(url, function (data) {
        callback(data);
    });
};

var getLoggedInUser = function getLoggedInUser_(callback) {
    var userId = getUserId();
    var url = "/api/users?id=".concat(userId);
    $.getJSON(url, function (data) {
        callback(data);
    });
};

function getUserId() {
    var all = document.cookie;
    var array = all.split(";");
    var UserId = -1;
    for (var i = 0; i < array.length; i++){
        var pos = array[i].indexOf("UserId");
        if (pos > 0)
            UserId = array[i].substring(array[i].indexOf("=")+1, array[i].length);
    }
    return UserId;
}